#include <QPainter>
#include <QImage>
#include "drawimage.h"

DrawImage::DrawImage(QWidget *parent) :
    QWidget(parent)
{
    pX = parent->width();
    pY = parent->height();
}

DrawImage::~DrawImage()
{

}

void DrawImage::endThis()
{
    this->close();
}

void DrawImage::setImagePath(const QString imagePath)
{
    iPath = imagePath;
}

void DrawImage::keyPressEvent(QKeyEvent *keyEvent)
{
    if (keyEvent->key()==Qt::Key_Escape)
    {
        this->close();
    }
//    emit escapeKeyPressed();
}

void DrawImage::paintEvent(QPaintEvent *pEvent)
{
    drawImage();
}

void DrawImage::drawImage()
{
    //TODO
    this->setAutoFillBackground(true);
    QPalette palette;
    palette.setColor(QPalette::Background, QColor(0,0,0));
    this->setPalette(palette);

    QPainter painter(this);
    QImage myImage(iPath);
    painter.drawImage(0,0, myImage, 0,0, myImage.width(), myImage.height());
}
